<?php

    $current_year = date('Y');
    $unix_timestamp = time();
    $max_year = $current_year + 2;

    echo $javascript->link('education_experiences');

?>

<script>

$(function() {
    
    /*
     * inizializza i bottoni utilizzati per aprire le dialog (site.js)
     */
    init_dialog_button('add_title', 'title_form');
    init_dialog_button('add_organization', 'organization_form');
    init_dialog_button('add_position', 'position_form');
    
    title_form_dialog("<?php echo $this->Html->url(array(
                                                        'controller' => 'EducationExperiences',
                                                        'action'    => 'add_title'
                                                    )); ?>");
                                                            
    organization_form_dialog("<?php echo $this->Html->url(array(
                                                            'controller' => 'EducationExperiences',
                                                            'action'    => 'add_organization'
                                                        )); ?>");
                                                                
    position_form_dialog("<?php echo $this->Html->url(array(
                                                            'controller' => 'EducationExperiences',
                                                            'action'    => 'add_position'
                                                        )); ?>");                                                            
 
});

</script>
<!-- Add title form dialog -->
<div id="title_form" title="Aggiungi un titolo di studio">
    <p class="validateTips">Tutte i campi sono obbligatori.</p>
    
    <form>
    <fieldset>
            <label for="title_name">Nome</label>
            <input type="text" name="title_name" id="title_name" class="text ui-widget-content ui-corner-all" />
    </fieldset>
    </form>

</div>
<!-- Add organization form dialog -->
<div id="organization_form" title="Aggiungi un'organizzazione/ente">
    <p class="validateTips">Tutte i campi sono obbligatori.</p>

    <fieldset>
            <label for="organization_name">Nome</label>
            <input type="text" name="organization_name" id="organization_name" class="text ui-widget-content ui-corner-all" />
            <label for="organization_address">Indirizzo</label>
            <input type="text" name="organization_address" id="organization_address" class="text ui-widget-content ui-corner-all" />
            <label for="organization_level">Livello</label>
            <input type="text" name="organization_level" id="organization_level" class="text ui-widget-content ui-corner-all" />
            <label for="organization_city">Città</label>
            <input type="text" name="organization_city" id="organization_city" class="text ui-widget-content ui-corner-all" />
    </fieldset>

</div>
<!-- Add position form dialog -->
<div id="position_form" title="Aggiungi Posizione">
    <p class="validateTips">Tutte i campi sono obbligatori.</p>
    
    <form>
    <fieldset>
            <label for="position_name">Nome</label>
            <input type="text" name="position_name" id="position_name" class="text ui-widget-content ui-corner-all" />
    </fieldset>
    </form>

</div>

<div id="test_dialog" title="Aggiungi un titolo di studio">
    
</div>

<?php

    echo $form->create('EducationExperience');

?>

<fieldset>
    <legend>
        Modifica esperienza di istruzione/formazione
    </legend>

<?php

    echo $form->input('from', array('label' => 'Da'));
    echo $form->input('to', array('label' => 'A'));
    echo $form->input('skills', array('label' => 'Abilit&agrave;',
                                      'rows' => '3'));
    echo $form->input('title_id', array(
                                 'empty' => '-- Seleziona --',
                                 'type' => 'select',
                                 'options' => $titles,
                                 'label' => 'Titolo'));
    
    echo $html->link('Aggiungi titolo', '#', array('onclick'=>'return false;', 'id'=>'add_title', 'class'=>''));

    echo $form->input('organization_id', array(
                                 'empty' => '-- Seleziona --',
                                 'type' => 'select',
                                 'options' => $organizations,
                                 'label' => 'Organizzazione/Ente'));

    echo $html->link('Aggiungi organizzazione', '#', array('onclick'=>'return false;', 'id'=>'add_organization', 'class'=>''));                             

    echo $form->input('position_id', array(
                                 'empty' => '-- Seleziona --',
                                 'type' => 'select',
                                 'options' => $positions,
                                 'label' => 'Posizione'));
    
    echo $html->link('Aggiungi posizione', '#', array('onclick'=>'return false;', 'id'=>'add_position', 'class'=>'')); 
    
    echo $form->input('person_id', array('type' => 'hidden'));
    echo $form->input('id', array('type' => 'hidden'));

?>
    
</fieldset>

<?php

echo $form->end('Salva');

?>